package com.august.config;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;

import javax.sql.DataSource;

@Configuration
public class JdbcTemplateDataSourceConfig {
    //JdbcTemplate主数据源ds1数据源
    @Primary
    @Bean(name = "mysql1JdbcTemplate")
    public JdbcTemplate mysql1JdbcTemplate(@Qualifier("mysql1DataSource") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }

    //JdbcTemplate第二个ds2数据源
    @Bean(name = "mysql2JdbcTemplate")
    public JdbcTemplate mysql2JdbcTemplate(@Qualifier("mysql2DataSource") DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }
}
